﻿using Microsoft.Graphics.Canvas;
using Microsoft.Graphics.Canvas.Effects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using Windows.Foundation;

namespace 纸片人.win2dEffectControl.DataClass
{
    public class BorderEffectData : EffectOneSourceData
    {
        #region 属性
        private CanvasEdgeBehavior _extendX = CanvasEdgeBehavior.Clamp;
        private CanvasEdgeBehavior _extendY = CanvasEdgeBehavior.Clamp;

        public CanvasEdgeBehavior ExtendX { get => _extendX; set { _extendX = value; OnPropertyChanged();SetIsChanges(); } }
        public CanvasEdgeBehavior ExtendY { get => _extendY; set { _extendY = value; OnPropertyChanged();SetIsChanges(); } }
        #endregion

        public override ICanvasImage GetEffect(CanvasDevice device, bool compression)
        {
            if (InputEffectData == null)
            {
                Size = new Windows.Foundation.Size(0, 0);
                return null;

            }

            var source = GetSourceEffect(device, compression);
            if (source == null)
            {
                Size = new Windows.Foundation.Size(0, 0);
                return null;

            }

            var effect = new BorderEffect()
            {
                ExtendX = ExtendX,
                ExtendY = ExtendY,
                Source = source,
            };



            Size =new Size( Size.Width * 2,Size.Height*2);
            return effect;
        }
    }
}
